package StudyCode.Interfaces;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;

/**
 * @author lixiaoyao
 */
public class TimerTest {
	public static void main(String[] args) {
		ActionListener listener = new TimerPrinter();

		//construct a timer that calls the listener
		// once every 10 seconds
		Timer t = new Timer(10000, listener);
		t.start();
		JOptionPane.showMessageDialog(null, "Quit program?");
		System.exit(0);
	}

}

class TimerPrinter implements ActionListener {

	@Override
	public void actionPerformed(ActionEvent event) {
		System.out.println("At the tore,the time is" + new Date());
		Toolkit.getDefaultToolkit().beep();
		Integer w=new Integer(1);
	}

}
